package com.engine.jsit.duss.utils;

import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2022-03-28
 * @Description: 信息学校工具类
 * @ModifyLog:
 **/

public class JsitUtil {

    //根据员工号获取人员ID
    public static int getHrmidByWorkcode(String workcode) {
        RecordSet rs = new RecordSet();
        rs.executeQuery( "select id from hrmresource where workcode =?", workcode );
        rs.next();
        int id = Util.getIntValue( rs.getString( "id" ), -1 );
        return id;
    }

    //获取目录是否存在
    public static boolean getSeccategory(String seccategory) {
        RecordSet rs = new RecordSet();
        rs.executeQuery( "select count(id) from docseccategory where id in (" + seccategory + ")" );
        rs.next();
        int id = Util.getIntValue( rs.getString(1), -1 );
        boolean flag = id > 0 ? true : false;
        return flag;
    }

    //根据员工号获取人员ID
    public static String getLastnameById(String id) {
        String lastnames = "";
        try {
            ResourceComInfo comInfo = new ResourceComInfo();
            String[] strs = id.split( "," );
            for (String str : strs) {
                String lastname = comInfo.getLastname( str );
                lastnames +="".equals(lastnames)?lastname:","+lastname;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return lastnames;
    }

}
